home *** CD-ROM | disk | FTP | other *** search
/ Aminet 35 / Aminet 35 (2000)(Schatztruhe)[!][Feb 2000].iso / Aminet / dev / src / td01_src.lha / td_r0.1 / sl3 / source / LibInit.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-17  |  4.9 KB  |  158 lines

  1. /*
  2. **      $VER: LibInit.c 37.31 (18.3.98)
  3. **
  4. **      Library initializers and functions to be called by StartUp.c
  5. **
  6. **      (C) Copyright 1996-98 Andreas R. Kleinert
  7. **      All Rights Reserved.
  8. **
  9. **      Modified by Stephan Bielman for 3do 3s modules, generic
  10. **
  11. **      Creation date     : 11.4.99
  12. **      Last modification : 16.5.99
  13. **
  14. */
  15.  
  16. #define __USE_SYSBASE        // perhaps only recognized by SAS/C
  17.  
  18. #include <exec/types.h>
  19. #include <exec/memory.h>
  20. #include <exec/libraries.h>
  21. #include <exec/execbase.h>
  22. #include <exec/resident.h>
  23. #include <exec/initializers.h>
  24.  
  25. #ifdef __MAXON__
  26. #include <clib/exec_protos.h>
  27. #else
  28. #include <proto/exec.h>
  29. #endif
  30. #include "compiler.h"
  31.  
  32. #ifdef __GNUC__
  33. #include "../../include/x3/x3base.h"
  34. #elif VBCC
  35. #include "include/x3/x3base.h"
  36. #else
  37. #include "/include/x3/x3base.h"
  38. #endif
  39.  
  40. ULONG __saveds __stdargs L_OpenLibs(struct x3Base *x3Base);
  41. void  __saveds __stdargs L_CloseLibs(void);
  42.  
  43. struct ExecBase      *SysBase       = NULL;
  44.  
  45. #ifdef DUMMY1
  46. #define VERSION  1
  47. #define REVISION 0
  48.  
  49. char __aligned tdo3XLibName [] = "dummy4.library";
  50. char __aligned tdo3XLibID   [] = "$VER:dummy4 1.0 (15.5.99)";
  51. #endif
  52.  
  53. char __aligned Copyright [] = "(C)opyright 1999 by Stephan Bielmann. All rights reserved.";
  54.  
  55.  
  56. /* ----------------------------------------------------------------------------------------
  57.    ! ROMTag and Library inilitalization structure:
  58.    !
  59.    ! Below you find the ROMTag, which is the most important "magic" part of a library
  60.    ! (as for any other resident module). You should not need to modify any of the
  61.    ! structures directly, since all the data is referenced from constants from somewhere else.
  62.    !
  63.    ! You may place the ROMTag directly after the LibStart (-> StartUp.c) function as well.
  64.    !
  65.    ! Note, that the data initialization structure may be somewhat redundant - it's
  66.    ! for demonstration purposes.
  67.    !
  68.    ! EndResident can be placed somewhere else - but it must follow the ROMTag and
  69.    ! it must not be placed in a different SECTION.
  70.    ---------------------------------------------------------------------------------------- */
  71.  
  72. extern ULONG InitTab[];
  73. extern APTR EndResident; /* below */
  74.  
  75. struct Resident __aligned ROMTag =     /* do not change */
  76. {
  77.  RTC_MATCHWORD,
  78.  &ROMTag,
  79.  &EndResident,
  80.  RTF_AUTOINIT,
  81.  VERSION,
  82.  NT_LIBRARY,
  83.  0,
  84.  &tdo3XLibName[0],
  85.  &tdo3XLibID[0],
  86.  &InitTab[0]
  87. };
  88.  
  89. APTR EndResident;
  90.  
  91. struct MyDataInit                      /* do not change */
  92. {
  93.  UWORD ln_Type_Init;      UWORD ln_Type_Offset;      UWORD ln_Type_Content;
  94.  UBYTE ln_Name_Init;      UBYTE ln_Name_Offset;      ULONG ln_Name_Content;
  95.  UWORD lib_Flags_Init;    UWORD lib_Flags_Offset;    UWORD lib_Flags_Content;
  96.  UWORD lib_Version_Init;  UWORD lib_Version_Offset;  UWORD lib_Version_Content;
  97.  UWORD lib_Revision_Init; UWORD lib_Revision_Offset; UWORD lib_Revision_Content;
  98.  UBYTE lib_IdString_Init; UBYTE lib_IdString_Offset; ULONG lib_IdString_Content;
  99.  ULONG ENDMARK;
  100. } DataTab =
  101. #ifdef VBCC
  102. {
  103.         0xe000,8,NT_LIBRARY,
  104.         0x0080,10,(ULONG) &ExLibName[0],
  105.         0xe000,LIBF_SUMUSED|LIBF_CHANGED,
  106.         0xd000,20,VERSION,
  107.         0xd000,22,REVISION,
  108.         0x80,24,(ULONG) &ExLibID[0],
  109.         (ULONG) 0
  110. };
  111. #else
  112. {
  113.  INITBYTE(OFFSET(Node,         ln_Type),      NT_LIBRARY),
  114.  0x80, (UBYTE) OFFSET(Node,    ln_Name),      (ULONG) &tdo3XLibName[0],
  115.  INITBYTE(OFFSET(Library,      lib_Flags),    LIBF_SUMUSED|LIBF_CHANGED),
  116.  INITWORD(OFFSET(Library,      lib_Version),  VERSION),
  117.  INITWORD(OFFSET(Library,      lib_Revision), REVISION),
  118.  0x80, (UBYTE) OFFSET(Library, lib_IdString), (ULONG) &tdo3XLibID[0],
  119.  (ULONG) 0
  120. };
  121. #endif
  122.  
  123.  
  124. /* ----------------------------------------------------------------------------------------
  125.    ! L_OpenLibs:
  126.    !
  127.    ! Since this one is called by InitLib, libraries not shareable between Processes or
  128.    ! libraries messing with RamLib (deadlock and crash) may not be opened here.
  129.    !
  130.    ! You may bypass this by calling this function fromout LibOpen, but then you will
  131.    ! have to a) protect it by a semaphore and b) make sure, that libraries are only
  132.    ! opened once (when using global library bases).
  133.    ---------------------------------------------------------------------------------------- */
  134.  
  135. ULONG __saveds __stdargs L_OpenLibs(struct x3Base *x3Base)
  136. {
  137.  SysBase = (*((struct ExecBase **) 4));
  138.  
  139.  x3Base->x3b_SysBase       = SysBase;
  140.  
  141.  return(TRUE);
  142. }
  143.  
  144. /* ----------------------------------------------------------------------------------------
  145.    ! L_CloseLibs:
  146.    !
  147.    ! This one by default is called by ExpungeLib, which only can take place once
  148.    ! and thus per definition is single-threaded.
  149.    !
  150.    ! When calling this fromout LibClose instead, you will have to protect it by a
  151.    ! semaphore, since you don't know whether a given CloseLibrary(foobase) may cause a Wait().
  152.    ! Additionally, there should be protection, that a library won't be closed twice.
  153.    ---------------------------------------------------------------------------------------- */
  154.  
  155. void __saveds __stdargs L_CloseLibs(void)
  156. {
  157. }
  158.